<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>单值二叉树</title>
</head>
<body>
  <script>
    function fn(root) {
      const num = root.val
      // 当root存在时（也就是为true），判断当前树的val是否等于num&&其左子树节点的val是否等于num&&其右子树节点val是否等于num
      const dfs = (root) => root ? num === root.val && dfs(root.left) && dfs(root.right) : true
      return dfs(root)
    }
    console.log(fn([1,1,1,1,1,null,1]))
  </script>
</body>
</html>